import express from 'express';
import adapterObj from './adapter.js';
import upload from './uploadAdapter'
const router = express.Router();
/**
 * 重定向页面
 * @param  {[type]} '*'   [description]
 * @param  {[type]} (req, res,          next [description]
 * @return {[type]}       [description]
 */
router.get('*.html', (req, res, next) => {
    let renderPath = req.path.substr(1);
    return res.render(renderPath);
});

router.post('*/saveImageFile.do', upload.upload);
router.post('*/saveFile.do', upload.upload);

router.get('/admin/agencyInfo/index2.do', (req, res, next) => {
    return res.redirect("/agency/agencyList.html");
});

router.get('/admin/AgencyContact/index.do', (req, res, next) => {
    return res.redirect("/agency/agencyContactList.html");
});

router.get('/admin/houseInfo/index.do', (req, res, next) => {
    return res.redirect("/houseSource/houseList.html");
});

router.get('/admin/HouseVerifyInfo/index.do', (req, res, next) => {
    return res.redirect("/verify/houseVerifyList.html");
});

router.get('/admin/HouseSignInfo/index.do', (req, res, next) => {
    return res.redirect("/verify/houseSignedList.html");
});

router.get('/admin/HouseSaleInfo/index.do', (req, res, next) => {
    return res.redirect("/sale/houseList.html");
});

router.get('/admin/HouseSaleControl/index.do', (req, res, next) => {
    return res.redirect("/sale/saleControlList.html");
});

router.get('/admin/BasicInfoEmployee/index.do', (req, res, next) => {
    return res.redirect("/basicInfo/employedd.html");
});

router.get('/admin/BasicInfoPermission/index.do', (req, res, next) => {
    return res.redirect("/basicInfo/permission.html");
});

router.get('*.do', (req, res, next) => {
    return new adapterObj(req, res);
});

router.post('*.do', (req, res, next) => {
    return new adapterObj(req, res);
});

router.get('/', (req, res, next) => {
    return res.redirect("/index.html");
});

module.exports = router;
